import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../wf/appclassic/home.vue'
import login from '../wf/appclassic/login.vue'
import myflow from '../wf/myFlow.vue'
import MyFlowGener from '../wf/myFlowGener.vue'
import MyFlowSelfForm from '../wf/myFlowSelfForm.vue'
import MyViewSelfForm from '../wf/myViewSelfForm.vue'
import MyView from '../wf/myView.vue'
import MyViewGener from '../wf/myViewGener.vue'
import start from '../wf/start.vue' //发起
import todolist from '../wf/todolist.vue' //待办
import runing from '../wf/runing.vue' // 在途
import complete from '../wf/complete.vue' //已完成

import batchbo from '../wf/batchbo.vue' //批处理
import draft from '../wf/draft.vue' //草稿
import send from '../wf/send.vue' // 抄送

import mysend from '../wf/comm/search.vue' //我发起的
import myjoin from '../wf/comm/search.vue' //我参与的
import beoverdue from '../wf/beoverdue.vue' //逾期

import demo from '../demo/demo.vue' //已完成
import Search from '../wf/comm/search.vue'
import EnOnly from '../wf/comm/enOnly.vue'

import GroupFieldModel from '../wf/workopt/GroupFieldModel.vue'//批处理
import batchList from '../wf/workopt/batchList.vue'//批处理

import Default from '../wf/default.vue' //个人中心
import Powerlist from '../wf/powerlist.vue' //授权列表
Vue.use(VueRouter)
// 重写路由的push方法

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

const routes = [
  {
    path: '/home',
    name: 'home',
    component: home,
    children: [
      {
        path: '/start',
        name: 'start',
        component: start,
      },
      {
        path: '/todolist',
        name: 'todolist',
        component: todolist,
      },
      {
        path: '/runing',
        name: 'runing',
        component: runing,
      },
      {
        path: '/searchZongHe',
        name: 'searchZongHe',
        component: () => import('@/wf/searchZongHe.vue'),
      },
      {
        path: '/complete',
        name: 'complete',
        component: complete,
      },
      //
      {
        path: '/batchbo',
        name: 'batchbo',
        component: batchbo,
      },
      {
        path: '/GroupFieldModel',
        name: 'GroupFieldModel',
        component: GroupFieldModel,
      },
      {
        path: '/batchList',
        name: 'batchList',
        component: batchList,
      },
      {
        path: '/draft',
        name: 'draft',
        component: draft,
      },
      {
        path: '/send',
        name: 'send',
        component: send,
      },
      {
        path: '/mysend',
        name: 'mysend',
        component: mysend,

      },
      {
        path: '/myjoin',
        name: 'myjoin',
        component: myjoin,
      },
      {
        path: '/beoverdue',
        name: 'beoverdue',
        component: beoverdue,
      },
      //
      {
        path: '/myflow',
        name: 'myflow',
        component: myflow
      },
      {
        path: '/MyFlowGener',
        name: 'MyFlowGener',
        component: MyFlowGener
      },
      {
        path: '/MyFlowSelfForm',
        name: 'MyFlowSelfForm',
        component: MyFlowSelfForm
      },
      {
        path: '/MyViewSelfForm',
        name: 'MyViewSelfForm',
        component: MyViewSelfForm
      },
      {
        path: '/MyView',
        name: 'MyView',
        component: MyView
      },
      {
        path: '/MyViewGener',
        name: 'MyViewGener',
        component: MyViewGener
      },
      {
        path: '/search',
        name: 'search',
        component: Search
      },
      {
        path: '/enOnly',
        name: 'enOnly',
        component: EnOnly
      },
      {
        path: '/default',
        name: 'Default',
        component: Default
      },
      {
        path: '/powerlist',
        name: 'powerlist',
        component: Powerlist
      }
    ]
  },
  {
    path: '/',
    name: 'login',
    component: login
  },

  {
    path: '/demo',
    name: 'demo',
    component: demo
  }
]

const router = new VueRouter({
  mode: 'history', //项目发布的时候需要设置成hash,否则发布项目运行会出现空白
  routes
})

export default router
